from urllib import request
import json

base_url = 'https://movie.douban.com/j/chart/top_list?type=11&interval_id=100%3A90&action=&start={}&limit=20'

res = ''
f = open('movie.json','w',encoding='utf-8')
res += '['

for i in range(0,200 + 1,20):
    fullurl = base_url.format(i)
    print(fullurl)
    response = request.urlopen(fullurl)
    data = response.read().decode('utf-8')
    data = json.loads(data) # 把json转化成字典
    for movie in data:
        # f.write(json.dumps(movie,ensure_ascii=False) + ',\n')
        res += json.dumps(movie,ensure_ascii=False) + ',\n'

res = res.strip(',\n')
res += ']'
f.write(res)
f.close()

# [
#     {},
#     {},
# ]
#